<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <ul id="ul"></ul>

  <script>

    function color16(){//十六进制颜色随机
      const r = Math.floor(Math.random()*256);
      const g = Math.floor(Math.random()*256);
      const b = Math.floor(Math.random()*256);
      const color = `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
      return color;
    }

    let now = Date.now();  //Date.now()得到时间戳

    const total = 100000
    const ul = document.getElementById('ul')

    for (let i = 0; i < total; i++) {
      let li = document.createElement('li')
      li.innerHTML = ~~(Math.random() * total)
      li.style.backgroundColor=color16()
      ul.appendChild(li)
    }
    console.log('js运行时间',Date.now()-now);  //这里触发时间是js加载完成

    setTimeout(()=>{  
      console.log('总时间',Date.now()-now);     //这里触发时间是已经渲染完成，也就是下一次Event Loop中执行的。
    },0)
  </script>
</body>

</html>